package com.cw2.behavioral.interpreter1;

import com.cw2.behavioral.interpreter.IDCardExpression;
import com.cw2.behavioral.interpreter.OrExpression;

import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * 定义具体的实现类
 */
public class Area1 {
    Set<String> type = new HashSet<>(Arrays.asList("老师","医生"));
    Set<String> city = new HashSet<>(Arrays.asList("武汉市","北京市"));

    IDCardExpression1 idCardExpression1;
    public Area1(){
        IDCardExpression1 city = new TerminalExpression1(this.city, ":");
        IDCardExpression1 type = new TerminalExpression1(this.type, ":");
        idCardExpression1 = new AndExpression1(city, type);
    }

    void check(String expression){
        boolean interpreter1 = idCardExpression1.interpreter1(expression);
        if (interpreter1){
            System.out.println("恭喜你免费通过");
        }else {
            System.out.println("对不起，请购票");
        }
    }


}
